package algorithm;

public class leetcode_0034 {
    public int[] searchRange(int[] nums, int target) {
        int []list=new int[2];
        list[0]=-1;list[1]=-1;
        if(nums==null) return list;
        int len=nums.length;
        int left=-1;
        int right=-1;
        for(int i=0,j=len-1;i<=j;++i,--j){
            if(nums[i]==target){
                left=i;--i;
            }
            if(nums[j]==target){
                right=j;++j;
            }
            if(left!=-1&&right!=-1) break;
        }

        list[0]=left;list[1]=right;
        return list;
    }
}
